'''
Created on Jan 14, 2012

FatSuit Rig Menue

@author: Christoph Westphal
'''

import maya.cmds as cmds

def createUI ():
    
    import fatSuit
    
    
    if cmds.menu('fatSuitMenu', exists=1):
        cmds.deleteUI('fatSuitMenu')
    
    fatSuitMenu = cmds.menu('fatSuitMenu', parent = 'MayaWindow', tearOff = True, allowOptionBoxes = True, label ='FatSuit')
    cmds.menuItem(label = "Update", command = 'import fatSuit; reload(fatSuit); reload(fatSuitMenu); fatSuitMenu.createUI()') 
    cmds.menuItem(parent = fatSuitMenu, subMenu=True, tearOff = True, label = 'Setup')
    cmds.menuItem(label = "Reset to Bind Pose", command = 'fatSuit.setPose(\'Bind Pose\')')
    cmds.menuItem(label = "Mirror Leg Settings", command = 'fatSuit.mirrorLegSettings()')
    cmds.setParent( '..', menu=True )
    cmds.menuItem(divider=1)
    cmds.menuItem(label = "FK", command =    
'''
if cmds.menuItem(\'align\', query = True, checkBox = True) == False: fatSuit.SwitchMode(fk = True, align = False)
elif cmds.menuItem(\'align\', query = True, checkBox = True) == True: fatSuit.SwitchMode(fk = True, align = True)
'''
    )
    
    cmds.menuItem(label = "IK", command = 
'''
if cmds.menuItem(\'align\', query = True, checkBox = True) == False: fatSuit.SwitchMode(fk = False, align = False)
elif cmds.menuItem(\'align\', query = True, checkBox = True) == True: fatSuit.SwitchMode(fk = False, align = True)
'''
    )
    cmds.menuItem(divider=1)
    cmds.menuItem('align', label = "Align", checkBox = True)    
    cmds.menuItem(divider=1)
   
    Pose = cmds.menuItem(parent = fatSuitMenu, subMenu=True, tearOff = True, label = 'Pose') 
    poseDict = fatSuit.readPoseDict()
    cmds.menuItem(label = "Save Pose", command = 'window = fatSuit.savePoseWindow()')
    cmds.menuItem(parent = Pose, subMenu=True, tearOff = True, label = 'Remove Pose')
    
    for i in poseDict:   
            cmds.menuItem(label = '%s' %i, command = 'fatSuit.removePose(\'%s\')'%i)
            cmds.menuItem(parent = Pose, divider=1) 
    
    for i in poseDict:   
            cmds.menuItem(parent = Pose, label = '%s' %i, command = 'fatSuit.setPose(\'%s\')'%i)

                
    cmds.menuItem(parent = fatSuitMenu, subMenu=True, tearOff = True, label = 'Select')
    cmds.menuItem(label = "All", command = 
'''
if cmds.menuItem(\'selIncSet\', query = True, checkBox = True) == False and cmds.menuItem(\'selIncMain\', query = True, checkBox = True) == False: fatSuit.sel(obj = [\'allCtrl_set\'])
elif cmds.menuItem(\'selIncSet\', query = True, checkBox = True) == True and cmds.menuItem(\'selIncMain\', query = True, checkBox = True) == False: fatSuit.sel(obj = [\'allCtrl_set\',\'allLegSettings_set\'])
elif cmds.menuItem(\'selIncSet\', query = True, checkBox = True) == True and cmds.menuItem(\'selIncMain\', query = True, checkBox = True) == True: fatSuit.sel(obj = [\'allCtrl_set\',\'allLegSettings_set\',\'mainCtrl_set\'])
elif cmds.menuItem(\'selIncSet\', query = True, checkBox = True) == False and cmds.menuItem(\'selIncMain\', query = True, checkBox = True) == True: fatSuit.sel(obj = [\'allCtrl_set\',\'mainCtrl_set\'])
'''
    )
    cmds.menuItem(divider=1)
    cmds.menuItem('selIncSet', label = "Include Leg Settings", checkBox = True)
    cmds.menuItem('selIncMain',label = "Include Main Ctrl", checkBox = False)
    cmds.menuItem(divider=1)
    cmds.menuItem(label = "Head", command = 'fatSuit.sel(obj = [\'Head_jnt\'])')
    cmds.menuItem(label = "Jaw", command = 'fatSuit.sel(obj = [\'Jaw_jnt_1\'])')
    cmds.menuItem(label = "Tongue", command = 'fatSuit.sel(obj = [\'tongueCtrl_set\'])')
    cmds.menuItem(label = "L Ear", command = 'fatSuit.sel(obj = [\'l_ear_jnt_1\',\'l_ear_jnt_2\',\'l_ear_jnt_3\',\'l_ear_jnt_4\'])')
    cmds.menuItem(label = "R Ear", command = 'fatSuit.sel(obj = [\'r_ear_jnt_1\',\'r_ear_jnt_2\',\'r_ear_jnt_3\',\'r_ear_jnt_4\'])')
    cmds.menuItem(divider=1)
    cmds.menuItem(label = "Neck", command = 'fatSuit.sel(obj = [\'neck_jnt_1\',\'neck_jnt_2\',\'neck_jnt_3\'])')
    cmds.menuItem(divider=1)
    cmds.menuItem(label = "Upper Spine", command = 'fatSuit.sel(obj = [\'FK_upper_spine_ctrl\'])')
    cmds.menuItem(label = "Lower Spine", command = 'fatSuit.sel(obj = [\'FK_lower_spine_ctrl\'])')
    cmds.menuItem(divider=1)
    cmds.menuItem(label = "Tail", command = 'fatSuit.sel(obj = [\'tail_jnt_1\',\'tail_jnt_2\',\'tail_jnt_3\',\'tail_jnt_4\'])')
    cmds.menuItem(divider=1)
    cmds.menuItem(label = "All Leg Settings", command = 'fatSuit.sel(obj = [\'allLegSettings_set\'])')
    cmds.menuItem(label = "Leg Settings", command = 'fatSuit.pfxSel(obj = [\'leg_settings\'])')
    cmds.menuItem(divider=1)
    cmds.menuItem(label = "IK Ctrl", command = 'fatSuit.pfxSel(obj = [\'leg_IK_mov_ctrl\'])')
    cmds.menuItem(divider=1)
    cmds.menuItem(label = "FK Shldr", command = 'fatSuit.pfxSel(obj = [\'leg_FK_shldr_ctrl\'])')
    cmds.menuItem(label = "FK Leg", command = 'fatSuit.pfxSel(obj = [\'leg_FK_upper_ctrl\',\'leg_FK_lower_ctrl\'])')
    cmds.menuItem(label = "FK Foot", command = 'fatSuit.pfxSel(obj = [\'leg_FK_foot_ctrl\',\'leg_FK_toe_ctrl\'])')
    #cmds.setParent('..')
    cmds.menuItem(parent = fatSuitMenu, subMenu=True, tearOff = True, label = 'Mirror')
    cmds.menuItem(label = "Mirror Leg", command = 'fatSuit.mirrorLegState()')
    cmds.menuItem(label = "Mirror FK Leg", command = 'fatSuit.mirrorFKleg()')
    cmds.menuItem(label = "Mirror IK Leg", command = 'fatSuit.mirrorIKleg()')
    cmds.menuItem(divider=1)  
    cmds.menuItem(label = "Include Leg Settings", checkBox = False, command = 'fatSuit.switchInclSet()')
    
    cmds.menuItem(parent = fatSuitMenu, subMenu=True, tearOff = True, label = 'Align')
    cmds.menuItem(label = "Align FK Shldr", command = 'fatSuit.alignFKshldr()')
    cmds.menuItem(d=1)
    cmds.menuItem(label = "Align FK Leg", command = 'fatSuit.alignFKblend()')
    cmds.menuItem(label = "Align FK Leg (IK)", command = 'fatSuit.alignFKleg(fik = False)')
    cmds.menuItem(label = "Align FK Leg (FullIK)", command = 'fatSuit.alignFKleg(fik = True)')
    cmds.menuItem(divider=1)
    cmds.menuItem(label = "Align IK Leg", command = 'fatSuit.alignIKleg()')
    #cmds.setParent('..')

def createItem ():
    
    fatSuitMenu = cmds.menu('fatSuitMenu', query = True)
    cmds.menuItem(parent = fatSuitMenu, label = "newItem", command = 'fatSuit.createItem()')

        